<template>
  <div class="home">
    <el-input v-model="userName" placeholder="请输入账号"></el-input>
    <el-input v-model="passWord" placeholder="请输入密码" show-password></el-input>
    <el-button @click="btnclick">登录</el-button>
  </div>
</template>

<script>
import { Login } from '@/api/user'

export default {
  name: 'HomeView',
  data() {
    return {
      userName: '',
      passWord: ''
    }
  },
  methods: {
    async btnclick() {
      let { data: { data, meta } } = await Login(this.userName, this.passWord)
      if (meta.status != 200) return this.$message.error(meta.msg);
      localStorage.setItem('admin_token', data.token)
      this.$router.push('/')
    }
  }
}
</script>

<style>
.home {
  padding: 12px 0;
  width: 280px;
  margin: 0 auto;
}

.home input {
  margin-bottom: 15px;
}

.home button {
  display: block;
  margin: 0 auto;
}
</style>